/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.openams.server.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author mike
 */
@Entity
@Table(name = "discreteassetassignments")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "DiscretAssetAssignment.findAll", query = "SELECT d FROM DiscretAssetAssignment d"),
    @NamedQuery(name = "DiscretAssetAssignment.findByDatasetInstanceAssignmentID", query = "SELECT d FROM DiscretAssetAssignment d WHERE d.datasetInstanceAssignmentID = :datasetInstanceAssignmentID")})
public class DiscretAssetAssignment implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "DatasetInstanceAssignmentID", nullable = false)
    private Long datasetInstanceAssignmentID;
    @JoinColumn(name = "DiscreteAssetID", referencedColumnName = "DiscreteAssetID")
    @ManyToOne(fetch = FetchType.LAZY)
    private DiscreteAsset discreteAssetID;
    @JoinColumn(name = "DatasetInstanceAssignmentID", referencedColumnName = "DatasetInstanceAssignmentID", nullable = false, insertable = false, updatable = false)
    @OneToOne(optional = false, fetch = FetchType.LAZY)
    private DatasetInstanceAssignment datasetInstanceAssignment;

    public DiscretAssetAssignment() {
    }

    public DiscretAssetAssignment(Long datasetInstanceAssignmentID) {
        this.datasetInstanceAssignmentID = datasetInstanceAssignmentID;
    }

    public Long getDatasetInstanceAssignmentID() {
        return datasetInstanceAssignmentID;
    }

    public void setDatasetInstanceAssignmentID(Long datasetInstanceAssignmentID) {
        this.datasetInstanceAssignmentID = datasetInstanceAssignmentID;
    }

    public DiscreteAsset getDiscreteAssetID() {
        return discreteAssetID;
    }

    public void setDiscreteAssetID(DiscreteAsset discreteAssetID) {
        this.discreteAssetID = discreteAssetID;
    }

    public DatasetInstanceAssignment getDatasetInstanceAssignment() {
        return datasetInstanceAssignment;
    }

    public void setDatasetInstanceAssignment(DatasetInstanceAssignment datasetInstanceAssignment) {
        this.datasetInstanceAssignment = datasetInstanceAssignment;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (datasetInstanceAssignmentID != null ? datasetInstanceAssignmentID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DiscretAssetAssignment)) {
            return false;
        }
        DiscretAssetAssignment other = (DiscretAssetAssignment) object;
        if ((this.datasetInstanceAssignmentID == null && other.datasetInstanceAssignmentID != null) || (this.datasetInstanceAssignmentID != null && !this.datasetInstanceAssignmentID.equals(other.datasetInstanceAssignmentID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.openams.server.entity.DiscretAssetAssignment[ datasetInstanceAssignmentID=" + datasetInstanceAssignmentID + " ]";
    }
    
}
